import time

f = open('m1_sorted.txt','r')
g = open('m2_reverse.txt','r')
h = open('m3_shuffle.txt','r')
#out= open('out.txt', 'w')
q = f.readlines()
w = g.readlines()
e = h.readlines()

result1=[]
result2=[]
result3=[]

for string in q:
    result1.append(int(string))
for string in w:
    result2.append(int(string))
for string in e:
    result3.append(int(string))

def bubble(result):
    for i in range(len(result)-1):
        for j in range(len(result)-i-1):
            if result[j] > result[j+1]:
                buff = result[j]
                result[j] = result[j+1]
                result[j+1] = buff
    

#print(result)
start_time1=time.time()
bubble(result1)
end_time1 = time.time()
elapsed_time1 = end_time1 - start_time1

start_time2=time.time()
bubble(result2)
end_time2 = time.time()
elapsed_time2 = end_time2 - start_time2

start_time3=time.time()
bubble(result3)
end_time3 = time.time()
elapsed_time3 = end_time3 - start_time3
#print(result)
#result.sort()
#print(result)

print('m1_sorted: ', "%d" % (elapsed_time1*1000), 'milliseconds')
print('m2_reverse: ', "%d" % (elapsed_time2*1000), 'milliseconds')
print('m3_shuffle: ', "%d" % (elapsed_time3*1000), 'milliseconds')
#for line in result:
    #out.write(str(line)+"\n")
f.close()
g.close()
h.close()
#out.close()
